import { request } from "@/utils/service"
import type * as InterfaceTypes from "./types/InterfaceTypes"
import { knowledgeParams } from "./types/InterfaceTypes"

/** 获取验证码 */
export function apiGetPhoneCode(data: InterfaceTypes.LoginRequestCode) {
  return request<any>({
    url: "code",
    method: "post",
    data
  })
}
/** 登录 */
export function apiGetAdminLogin(data: InterfaceTypes.LoginRequestparams) {
  return request<any>({
    url: "index/login",
    method: "post",
    data
  })
}

// 获取管理员列表
export function apiUserList(data: any) {
  return request<InterfaceTypes.administratorsparams>({
    url: "/user/list",
    method: "post",
    data
  })
}
// 添加管理员
export function apiUserAdd(data: any) {
  return request<InterfaceTypes.knowledgeparams>({
    url: "/user/add",
    method: "post",
    data
  })
}
// 禁用管理员
export function apiUserDisable(data: any) {
  return request<InterfaceTypes.knowledgeparams>({
    url: "/user/del",
    method: "post",
    data
  })
}
//end

// 知识库Api=>知识库列表
export function knowledgeList(data: any) {
  return request<InterfaceTypes.knowledgeparams>({
    url: "knowledge/list",
    method: "post",
    data
  })
}

// 知识库创建/更新
export function apIknowledSave(data: knowledgeParams) {
  return request<InterfaceTypes.knowledgeparams>({
    url: "knowledge/add",
    method: "post",
    data
  })
}

// 知识库删除
export function apIknowledDelete(data: { id: number }) {
  return request<any>({
    url: "knowledge/del",
    method: "post",
    data
  })
}

//知识库上传
export function apiUp_file(data: any) {
  return request<any>({
    url: "knowledge/up_file",
    method: "post",
    data,
    headers: {
      // 'Content-Type': "multipart/form-data",
      // credentials: 'same-origin',
      "Content-Type": false,
      "Process-Data": false
    }
    // responseType: 'blob'
  })
}

// 获取单个知识库的信息

export function apiKnowledgeGet(data: { id: number }) {
  return request<any>({
    url: "/knowledge/get",
    method: "post",
    data
  })
}

// 获取知识库里面的文件
export function apiKnowledgeFileGet(data: { knowledge_id: number }) {
  return request<any>({
    url: "/knowledge/get_file",
    method: "post",
    data
  })
}

// 删除知识库里面的文件
export function apiFileDelete(data: { id: number }) {
  return request<any>({
    url: "/knowledge/del_file",
    method: "post",
    data
  })
}
// end

// 获取日志
export function APILogList(data: any) {
  return request<any>({
    url: "/log/list",
    method: "post",
    data
  })
}

// 获取个人信息
export function APIUserList() {
  return request<any>({
    url: "/user/info",
    method: "post"
  })
}

// 修改个人信息
export function APIUserUpInfo(data: any) {
  return request<any>({
    url: "/user/up_info",
    method: "post",
    data,
    headers: {
      // 'Content-Type': "multipart/form-data",
      // credentials: 'same-origin',
      "Content-Type": false,
      "Process-Data": false
    }
  })
}

// 获取看板数据
export function APIStatisticsData(data: { start_time: string; end_time: string }) {
  return request<any>({
    url: "/index/statistics",
    method: "post",
    data
  })
}

//获取订单数据
export function APIDateBill(data: { start_time: string; end_time: string }) {
  return request<any>({
    url: "/index/date_bill",
    method: "post",
    data
  })
}

// 获取代理节点
export function APIGetAgent(data: { robot_id: number }) {
  return request<any>({
    url: "/robot/get_agent",
    method: "post",
    data
  })
}

// 更新代理节点
export function APIUpAgent(data: { robot_id: number; agent: string }) {
  return request<any>({
    url: "/robot/up_agent",
    method: "post",
    data
  })
}
